{extend name='public/_home' /}

{block name='title'}评论列表{/block}

{block name='main'}
<!-- Page Content -->
<div class="page-content">
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li class="active">
                <i class="fa fa-home"></i>&nbsp;评论列表
            </li>
        </ul>
    </div>
    <!-- /Page Breadcrumb -->
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-xs-12">
                <div class="widget">
                    <div class="widget-header">
                        <span class="widget-caption">评论列表</span>
                        <div class="widget-buttons">
                            {$comments|raw|replace}
                        </div>
                    </div>
                    <div class="widget-body">
                        <table class="table table-hover table-bordered">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>文章</th>
                                <th>会员</th>
                                <th>内容</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="comments" id="vo"}
                            <tr>
                                <td>{$vo.id}</td>
                                <td>{$vo.articles.title}</td>
                                <td>{$vo.members.username}</td>
                                <td>{$vo.content}</td>
                                <td>
                                    <a href="#" class="btn btn-danger btn-xs comment-del" data-id="{$vo.id}">删除</a>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /Page Body -->
</div>
<!-- /Page Content -->
{/block}
{block name="js"}
<script>
    $(function () {
        $(".pagination").addClass("pagination-sm");
        //删除按钮
        $('.comment-del').click(function () {
            console.log(11111111);
            let id = $(this).data('id');
            layer.confirm('确定删除？', {
                icon: 3,
            }, function () {
                layer.close();
                $.ajax({
                    url: "{:url('admin/comment/del')}",
                    type: "post",
                    data: {id},
                    dataType: "json",
                    success: function (data) {
                        if (data.code == 1) {
                            layer.msg(data.msg, {
                                icon: 6,
                                time: 2000
                            }, function () {
                                location.href = data.url
                            })
                        } else {
                            layer.open({
                                title: "操作失败",
                                icon: 5,
                                content: data.msg
                            })
                        }
                    }
                });
            })
            return false;
        });
    });
</script>
{/block}